package com.sam.im.heiqun.uis.adapters.holder;

/**
 * Created by wangguodong on 2017/1/10.
 */

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.sam.im.heiqun.R;
import java.util.List;

public class PopListAdapter extends BaseAdapter {
    private List<String> mList = null;//定义一个list对象
    private Context mContext;//上下文
    String xTAG = "emoji";
    /**
     * 构造方法
     * @param context 上下文
     * @param list 所有APP的集合
     */
    public PopListAdapter(Context context, List<String> list) {
        mContext = context;
        mList = list;
    }
    public int getCount() {
        // TODO Auto-generated method stub
        return mList.size();
    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return mList.get(position);
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder vh = null;
        if(convertView == null){
            convertView = LayoutInflater.from(mContext).inflate(R.layout.pop_list_item, parent,false);
            vh = new ViewHolder();
            vh.name = (TextView) convertView.findViewById(R.id.txt_name);
            convertView.setTag(vh);
        }else{
            vh = (ViewHolder) convertView.getTag();
        }

        vh.name.setText(mList.get(position));
        return convertView;
    }
    class ViewHolder{
        TextView name;
    }
}

